﻿// JScript File

function checkDatePeriod()
{
  alert("23232132");  
  var myDate = new Date(document.getElementById('<%= TextBox1.ClientID %>').value);
  alert(myDate);  
  var beforDate = new Date($get('<%= txt_NewsDate.ClientID %>').value);
  alert(beforDate);  
    if(beforDate != "undefined")
    {
        alert(beforDate);                   
    }
}


// Register a new Namespace
Type.registerNamespace("SiteECSWeb");

// Define the constructor of the Location class
SiteECSWeb.Location = function (uiElement, uiBody, uiProgress) {
    // Call base class just for completeness
    SiteECSWeb.Location.initializeBase(this);
    
    this._uiElement = uiElement;
    this._uiBody = uiBody;
    this._uiProgress = uiProgress;
    this._xAxis = 0;
    this._yAxis = 0;
}

// Define the properties and methods of the Location class
// using the Prototype Design Pattern
SiteECSWeb.Location.prototype= {
    
    // Define UIElement Property
    get_uiElement:function() {
        // Get
        return this._uiElement;
    },
    set_uiElement:function(value) {
        // Set
        this._uiElement = value;
    },
    
    // Define UIBody Property
    get_uiBody:function() {
        // Get
        return this._uiBody;
    },
    set_uiBody:function(value) {
        // Set
        this._uiBody = value;
    },
    
    // Define UIProgress Property
    get_uiProgress:function() {
        // Get
        return this._uiProgress;
    },
    set_uiProgress:function(value) {
        // Set
        this._uiProgress = value;
    },

    // Define ShowPopupInfo method that is responsible
    // for calling the webservice, and setting the location
    // of the popup window.
    ShowPopupinfo:function(event, areaName) {
        // Call the AJAX Service
        SiteECSWeb.LocationService.GetAreaInfoPlus2(
            areaName,                                         // Parameter
            Function.createDelegate(this, this.OnCompleted),  // Success Callback
            this.OnError,                                     // Failure Callback
            this.OnTimeOut);    // TimeOut Callback
            
                        
        ///modified by me 13-08-2009
        // Set the location of the popup window //window.innerHeight
        var scrOfX = 0, scrOfY = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
           //Netscape compliant
           scrOfY = window.pageYOffset;
           scrOfX = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
           //DOM compliant
           scrOfY = document.body.scrollTop;
           scrOfX = document.body.scrollLeft;
        } else if( document.documentElement && 
            ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
           //IE6 standards compliant mode
           scrOfY = document.documentElement.scrollTop;
           scrOfX = document.documentElement.scrollLeft;
        }
       
        this._xAxis =event.clientX + scrOfX;
        this._yAxis =event.clientY + scrOfY;
        //alert(scrOfX +" " +event.clientX + " " + event.clientY +" " +scrOfY );
 

        // Show the Progress Bar
        var progress = $get(this.get_uiProgress());
        if (progress != null) {
            progress.style.visibility = "visible";
            progress.style.display = "block";
        }
    },
    
    // Define HidePopupInfo method that is used to hide
    // the UI popup window
    HidePopupInfo:function() {
        var uiElement = $get(this.get_uiElement());
        if (uiElement != null) {
            uiElement.style.visibility = "hidden";
            uiElement.style.display = "none";
        }
        
        // Hide the progress bar
        this.hideProgressBar();
    },
    
    // Define success callback function that will update the UI
    // with the data coming frmo the AJAX Service
    OnCompleted:function(result, userContext, methodName) {
        var uiElement = $get(this.get_uiElement());
        var uiBody = $get(this.get_uiBody());
        
        if (uiBody != null) {
            uiBody.innerHTML = "<h3>مكــتب: "+result.Name+"</h3><h4><span class=oz_bold>رئيس المكتب:"+
                            "</span><br/><span class=oz_redbold>"
                             + result.HeadOfficer +"</span><br/><br/><table cellpadding=0 cellspacing=0><tbody>"+
                             "<tr><td class=oz_bold>تليفون المكتب:</td><td class=oz_bold>فاكس المكتب:</td>"+
                             "</tr><tr><td><span class=oz_num>"
                             + result.Tel +"</span></td></td><td><span class=oz_num>"
                             + result.Fax+"</span></td></tr></tbody></table>"+
                             "<span class=oz_bold>البريد الالكترونى:</span><br/>"
                             + result.Email+"<br/><span class=oz_bold>سعر صرف العملة:</span><br/><span class=oz_exchg>"
                             + result.Currency+
                             "</span><br/><span class=oz_bold>الوقت الآن:</span><br/><span class=oz_fun>"
                             +result.TimeNow+
                             "</span></h4>";            

            
            // Show the UI element
            if (uiElement != null) {
                uiElement.style.visibility = "visible";
                uiElement.style.display = "inline";
                uiElement.style.left = this._xAxis + "px";
                uiElement.style.top = this._yAxis + "px";
            }
        }
        
        // Hide the progress bar
        this.hideProgressBar();
    },
    
    // Error callback function to alert
    // the user that some exceptions were thrown
    // during the asynchronous processing
    onError:function(result, userContext, methodName) {
        // Hide the progress bar
        this.hideProgressBar();
        
        var msg = result.get_exceptionType() + "\r\n";
        msg += result.get_message() + "\r\n";
        msg += result.get_stackTrace();
        alert(msg);
    },    
    
    // Timeout callabck function called
    // when the current asynchronous request
    // times out
    onTimeOut:function(result, userContext, methodName) {
        // Hide the progress bar
        this.hideProgressBar();
        
        alert("Request Timeout :" + result);
    },
    
    hideProgressBar: function() {      
        // Hide the Progress Bar
        var progress = $get(this.get_uiProgress());
        if (progress != null) {
            progress.style.visibility = "hidden";
            progress.style.display = "none";
        }
    }
}

// Register the class
SiteECSWeb.Location.registerClass("SiteECSWeb.Location");

var mylocation = null;
function pageLoad(sender, args) {
    // Create a new instance of the class
    mylocation = new SiteECSWeb.Location("oz_rome", "oz_contbox", "updateProgress");    
    // Hide the popup div
    mylocation.HidePopupInfo();
}

// Method called by the page controls
// to update the UI with the information
// from the ajax service
function GetAreaInfo(event, args) {
    mylocation.ShowPopupinfo(event, args);
}

function HidePopup() {
    // Hide the popup div
    mylocation.HidePopupInfo();
}

